<?php
class Register_Model extends CI_Model {
	//spSaveCustomerInfo will return a result field:
	// -1 : email existed, -2 : username existed, 0 : failure, 1 : success
	
	const EMAIL_EXISTED = -1;
	const USERNAME_EXISTED = -2;
	const FAILURE = 0;
	const SUCCESS = 1;
	
	const INSERTUSER_STMT = 'CALL spSaveCustomerInfo(?, ?, ?, ?, ?, ?, ?, ?)';
	//const ACTIVATEEMAIL_STMT = 'CALL spActivateEmail(?, ?)';
	public function __construct() {
		$this->load->database();
	}
	
	public function insert_customer($customer) {
		$query = $this->db->query(self::INSERTUSER_STMT, $customer);
		$result = $query->row()->result;
		$query->next_result();
		$query->free_result();
		return $result;
	}
	/*
	public function activate_email($email, $key) {
		$query = $this->db->query(self::ACTIVATEEMAIL_STMT, array($email, $key));
		return $this->db->affected_rows();
	}*/
}
?>